package torres.map.tile;

import torres.entity.Entity;
import torres.map.effect.*;
import torres.item.Item;

/**
 * @author Torres
 * Represents a basic tile.
 */
@SuppressWarnings("serial")
public class ConcreteTile implements Tile {
	
	private Entity entity;
	private Item item;
	private Terrain terrain;
	private AreaEffect effect;
	
	/**
	 * Creates a new ConcreteTile with nothing occupying it.
	 */
	public ConcreteTile() {
		
		entity = null;
		item = null;
		terrain = null;
		effect = null;
	}
	
	/**
	 * Creates a new ConcreteTile with the specified Terrain.
	 * @param terrain The Terrain type of this tile.
	 */
	public ConcreteTile( Terrain terrain ) {
		
		this();
		this.terrain = terrain;
	}
	
	/**
	 * Creates a new ConcreteTile with the specified Terrain and specified AreaEffect.
	 * @param terrain The Terrain type of this tile.
	 * @param effect The effect to be applied to this tile.
	 */
	public ConcreteTile( Terrain terrain, AreaEffect effect ) {
		
		this();
		this.terrain = terrain;
		this.effect = effect;
	}
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#addEntity(torres.entity.Entity)
	 */
	public void addEntity(Entity entity) {
		
		this.entity = entity;
	}
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#addItem(torres.item.Item)
	 */
	public void addItem(Item item) {
		
		this.item = item;
	}
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#addTerrain(torres.map.tile.Terrain)
	 */
	public void addTerrain(Terrain terrain) {
		
		this.terrain = terrain;
	} 
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#addEffect(torres.map.effect.AreaEffect)
	 */
	public void addEffect(AreaEffect effect) {
		
		this.effect = effect;
	} 
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#removeEntity()
	 */
	public void removeEntity() {
		
		entity = null;
	}
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#removeEffect()
	 */
	public void removeEffect() {
		
		effect = null;
	}
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#removeItem()
	 */
	public void removeItem() {
		
		item = null;
	}
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#getItem()
	 */
	public Item getItem() {
		
		return item;
	}
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#getEntity()
	 */
	public Entity getEntity() {
		
		return entity;
	}
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#getEffect()
	 */
	public AreaEffect getEffect() {
		
		return effect;
	}
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#getTerrain()
	 */
	public Terrain getTerrain() {
		
		return terrain;
	}

	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#hasEntity()
	 */
	public boolean hasEntity() {
		
		return (entity != null);
	}
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#hasItem()
	 */
	public boolean hasItem() {
		
		return (item != null);
	}

	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#hasEffect()
	 */
	public boolean hasEffect() {
		
		return (effect != null);
	}
	
	/**
	 * Returns the String representation of this tile.
	 * @return The String representation of this tile.
	 */
	public String toString() {
		
		return terrain.toString();
	}
	
	/* (non-Javadoc)
	 * @see torres.map.tile.Tile#getImageName()
	 */
	public String getImageName() {
		return terrain.getImageName();
	}
}
